//
//  ZYCCircleFriendsCell.m
//  ZDSC
//
//  Created by ZDTX on 2021/9/19.
//

#import "ZYCCircleFriendsCell.h"
#import "ZYCCircleFriendPhotoView.h"
#import "ZYCCycleFriendModel.h"
#import "NSDateExtra.h"
@interface ZYCCircleFriendsCell ()

@property (nonatomic, strong) UILabel *dayLabel;
@property (nonatomic, strong) UILabel *monthLabel;
@property (nonatomic, strong) ZYCCircleFriendPhotoView *photoView;
@property (nonatomic, strong) UILabel *contentLabel;
@property (nonatomic, strong) UILabel *totalLabel;


@end

@implementation ZYCCircleFriendsCell
-(void)setModel:(ZYCCycleFriendModel *)model{
    _model = model;
    if (model.isShow) {
        _dayLabel.hidden = NO;
        _monthLabel.hidden = NO;
        _dayLabel.text = model.uploadDay;
        _monthLabel.text = [NSString stringWithFormat:@"%@月",model.uploadMonth];
    }else{
        _dayLabel.hidden = YES;
        _monthLabel.hidden = YES;
    }

    _totalLabel.text = [NSString stringWithFormat:@"共%zd张",model.total];
    _contentLabel.text = model.content;
    if (model.busFileList.count > 0) {
        self.photoView.hidden = NO;
        self.totalLabel.hidden = NO;
        self.photoView.busFileList = model.busFileList;
        [self.contentLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
//            make.left.equalTo(self.monthLabel.mas_right).offset(12.5f);
            make.left.equalTo(self.contentView).offset(166.0f);
            make.top.equalTo(self.contentView);
            make.right.equalTo(self.contentView).offset(-10.0f);
        }];
    }else{
        self.photoView.hidden = YES;
        self.totalLabel.hidden = YES;
        [self.contentLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
//            make.left.equalTo(self.monthLabel.mas_right).offset(12.5f);
            make.left.equalTo(self.contentView).offset(79.0f);
            make.top.equalTo(self.contentView);
            make.right.equalTo(self.contentView).offset(-10.0f);
        }];
    }
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self.contentView addSubview:self.dayLabel];
        [self.contentView addSubview:self.monthLabel];
        [self.contentView addSubview:self.photoView];
        [self.contentView addSubview:self.contentLabel];
        [self.contentView addSubview:self.totalLabel];

        [self.dayLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.contentView);
            make.left.equalTo(self.contentView).offset(10.0f);
        }];
        [self.monthLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.dayLabel.mas_centerY);
            make.left.equalTo(self.dayLabel.mas_right).offset(5.0f);
        }];
        
        [self.photoView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView).offset(79.0f);
            make.top.equalTo(self.contentView);
            make.size.mas_equalTo(CGSizeMake(81.0f, 81.0f));
        }];
        
        [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView).offset(166.0f);
            make.top.equalTo(self.contentView);
            make.right.equalTo(self.contentView).offset(-10.0f);
        }];
        
        [self.totalLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentLabel.mas_left);
            make.bottom.equalTo(self.contentView);
        }];
    }
    return self;
}

- (UILabel *)dayLabel {
    if (!_dayLabel) {
        _dayLabel = [UILabel LabelWithFont:kCustomFont(@"PingFangSC-Semibold", 28.0f) titleColor:HEX_RGB(@"#2B302D") textAlignment:ZZTextAlignmentLeft];
    }
    return _dayLabel;
}

- (ZYCCircleFriendPhotoView *)photoView {
    if (!_photoView) {
        _photoView = [[ZYCCircleFriendPhotoView alloc] init];
        _photoView.layer.cornerRadius = 3.0f;
        _photoView.layer.masksToBounds = YES;
    }
    return _photoView;
}
- (UILabel *)monthLabel {
    if (!_monthLabel) {
        _monthLabel = [UILabel LabelWithFont:kCustomFont(@"PingFangSC-Semibold", 14.0f) titleColor:HEX_RGB(@"#2B302D") textAlignment:ZZTextAlignmentLeft];
    }
    return _monthLabel;
}

- (UILabel *)contentLabel {
    if (!_contentLabel) {
        _contentLabel = [UILabel LabelWithFont:kCustomFont(@"PingFangSC-Regular", 15.0f) titleColor:HEX_RGB(@"#2B302D") textAlignment:ZZTextAlignmentLeft];
        _contentLabel.numberOfLines = 3;
    }
    return _contentLabel;
}

- (UILabel *)totalLabel {
    if (!_totalLabel) {
        _totalLabel = [UILabel LabelWithFont:kCustomFont(@"PingFangSC-Light", 12.0f) titleColor:HEX_RGB(@"#999999") textAlignment:ZZTextAlignmentLeft];
    }
    return _totalLabel;
}



@end
